package com.app.designpattern.creation.prototype.clone;

import java.util.Date;

/**
 * USER: zjw
 * DATA: 2019/4/12 0012
 * TIME: 上午 11:09
 */
public class Pig implements Cloneable {
    private String name;
    private Date brithday;

    public Pig(String name, Date brithday) {
        this.name = name;
        this.brithday = brithday;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getBrithday() {
        return brithday;
    }

    public void setBrithday(Date brithday) {
        this.brithday = brithday;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        Pig pig = (Pig) super.clone();
        pig.brithday = (Date) pig.brithday.clone();
        return pig;
    }

    @Override
    public String toString() {
        return "Pig{" +
                "name='" + name + '\'' +
                ", brithday=" + brithday +
                '}' + super.toString();
    }
}
